package com.sxhuayuan.parking.utils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/** 正则表达式工具类 */
public class PatternUtils {

	public static boolean matcherAll(String str, String regEx) {
		Pattern pattern = Pattern.compile(regEx);
		Matcher matcher = pattern.matcher(str);
		return matcher.matches();
	}

	/** 正则验证车牌号 */
	public static boolean matcherCarPlate(String str) {
		String regEx = "([京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}(([0-9]{5}[DF])|([DF]([A-HJ-NP-Z0-9])[0-9]{4})))|([京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}[A-HJ-NP-Z0-9]{4}[A-HJ-NP-Z0-9挂学警港澳]{1})";
		String s = str;
		return matcherAll(s, regEx);
	}

	public static void main(String[] args) {
		System.out.println(matcherCarPlate("粤BD11111"));
	}
}
